<template>
  <v-layout type="main">
    <!--    <div class="alick-handle">-->
    <!--      <el-button class="add-btn" @click="add">添加</el-button>-->
    <!--      <el-input class="search-item" v-model="Pagedata.name">-->
    <!--        <el-button slot="append" icon="el-icon-search" @click="getData"/>-->
    <!--      </el-input>-->
    <!--    </div>-->
    <el-table :data="tableData">
      <el-table-column prop="update_time" label="操作时间" />
      <el-table-column prop="update_user.nick_name" width="150" label="操作人" />
      <el-table-column prop="url" width="320" label="地址" />
      <el-table-column prop="description" width="320" label="说明" />
      <el-table-column prop="spend_time" width="170" label="响应时间（ms）" />
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button @click="goToDetail(scope.row)" type="text" size="small">
            查看详情
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="pagination-box" v-if="Pagedata.total > Pagedata.pageSize">
      <el-pagination background class="pagination" layout="total, prev, pager, next, jumper"
        :page-size="Pagedata.pageSize" :current-page.sync="Pagedata.pageNum" @current-change="handleCurrentChange"
        :total="Pagedata.total">
      </el-pagination>
    </div>
  </v-layout>
</template>
<script>
import { getAllOperateLog } from "../../api/operateLog";

export default {
  data() {
    return {
      tableData: [],
      addForm: {},
      showAddFormDailog: false,
      imageOptions: [],
      Pagedata: {
        pageNum: 1,
        pageSize: 10,
        total: 0,
        name: "", // 名称搜索
        order: "create_time", // 排序recommend、createTime、likeCount
      },
    };
  },
  async created() {
    this.getData()
  },
  methods: {
    handleCurrentChange(val) {
      this.Pagedata.pageNum = val
      this.getData()
    },
    async getData() {
      let res = await getAllOperateLog({ ...this.Pagedata })
      this.tableData = res.data.list
      this.Pagedata.total = res.data.total
      this.Pagedata.pageNum = res.data.page_num
      this.Pagedata.pageSize = res.data.page_size
      console.log("res", res)
    },
    goToDetail(row) {
      let query = {
        id: row.id
      }
      this.$router.push({
        path: '/operateLog/detail',
        query
      })
    }
  },
}
</script>
<style lang="less" scoped>
.page_box {
  display: flex;
  justify-content: end;
  width: 100%;
  padding: 25px 30px;
  box-sizing: border-box;
}
</style>
